home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-20 / rs0422.zip / CONFIGUR / MEMSIZ.C < prev    next >
C/C++ Source or Header  |  1989-12-09  |  6KB  |  186 lines

  1. /*
  2.  * Copyright 1988 by the Radio Amateur Telecommunications Society
  3.  * and Thomas A. Moulton, W2VY
  4.  *
  5.  * This software may only be modified, copied, distributed or
  6.  * executed for non-profit purposes by individuals operating
  7.  * systems in the Amateur Radio Service.  Credit to the
  8.  * author(s) and to the Radio Amateur Telecommunications Society
  9.  * must be made in modules where RATS provided software is used,
  10.  * and in any announcements and documentation.  
  11.  *
  12.  * As a non-profit, research and development organization,  the
  13.  * Radio Amateur Telecommunications Society distributes software
  14.  * in both executable and source forms.  This policy is in place
  15.  * to encourage the development and distribution of OSI-based,
  16.  * networking tools.  In order to protect the interests of the
  17.  * Society and the authors, we have placed some conditions
  18.  * of use on the software.  Other groups are encouraged
  19.  * to place the same or similar guidelines on
  20.  * software they produce.
  21.  *
  22.  * The Radio Amateur Telecommunications Society reserves the right
  23.  * to specify and alter the terms under which software provided by
  24.  * the Society may be used.  This policy is consistent with the 
  25.  * objective of uniform and consistent "Open Systems Interconnections."
  26.  * 
  27.  * All acceptable Amateur Radio related uses of this software
  28.  * will be outlined in the "ROSE Implementer's Guide".  Individuals
  29.  * or organizations wishing to add to, or modify the provisions of
  30.  * the guide to accommodate local or evolutionary requirements
  31.  * should document the proposed change(s) and forward them to the
  32.  * Society.  If accepted, written notification will be provided by
  33.  * the Society to the submitting organization or individual(s).
  34.  * The Society will then issue a "ROSE Implementer's Guide Change
  35.  * Notice".  Periodically, the Society will re-issue the "ROSE 
  36.  * Implementer's Guide" and incorporate the text of the change 
  37.  * notices.  This procedure has been put in to place to ensure
  38.  * compatibility between systems and to ensure their "Openness"
  39.  * and interoperability.
  40.  *
  41.  * No part of this software may be used in other packages 
  42.  * without prior authorization from the author or the Society.  
  43.  * Software incorporating this module, all or in part, must be 
  44.  * provided to the Society prior to distribution or use by
  45.  * anyone not directly involved in testing of the revised  
  46.  * environment.  Current releases of the combined software must
  47.  * be provided to the Society in both source and executable
  48.  * forms.  Adequate documention to produce an executable module 
  49.  * from the provided source must also be included.
  50.  *
  51.  * Non-Amateur Radio non-profit uses may be authorized on a case
  52.  * by case basis.  Inquiries for such use may be made in writing
  53.  * to the Society. Non-commercial uses consistent with the
  54.  * general principles of Open Systems Interconnection Reference
  55.  * Model will be generally considered with favor.
  56.  *
  57.  * Commercial licensing of the software is also available based
  58.  * on normal commercial terms.  Licensing inquiries should be
  59.  * directed to the Society.  Commercial licensing of the standard
  60.  * software will be done in situations which materially benefit
  61.  * the Amateur Radio Packet Network.  Additional licensing is
  62.  * reserved by the individual authors.
  63.  * 
  64.  * The Radio Amateur Telecommunications Society provides this software
  65.  * on an "as is" basis.  The Society assumes no liability for
  66.  * loss incurred through the use of this software.  Amateur Radio
  67.  * use of this software implies non-commercial and voluntary 
  68.  * development, deployment and use of this software in a "Amateur",
  69.  * non-commercial service.  Commercial users are encouraged to
  70.  * inspect their copies of the source code.  Source code modification
  71.  * licenses are available if a combined Object and Source Code
  72.  * license was not originally established.
  73.  * 
  74.  * The Society may be contacted by writing or calling at:
  75.  * 
  76.  * The Radio Amateur Telecommunications Society 
  77.  * 206 North Vivyen Street.
  78.  * Bergenfield, New Jersey 07621
  79.  *
  80.  * Telephone: 201-387-8896
  81.  *
  82.  */
  83. #include "data.h"
  84. #include "buffer.h"
  85. #include "iface.h"
  86. #include "timer.h"
  87. #include "ax25.h"
  88. #include "ax25l2.h"
  89. #include "l3struc.h"
  90. #include "x25cause.h"
  91. #include "l3calls.h"
  92. #include "tx.h"
  93. #include "config.h"
  94. #include "upfcn.h"
  95.  
  96. int NULLFCN(), clr_config(), con_config(), recv_boot();
  97. int send_config(), rst_boot(), unload_ok();
  98.  
  99. struct upfcn config={
  100.     {{0x9a, 0x8a, 0x9a, 0xa6, 0x92, 0xb4}, {0x00}}, /* MEMSIZ-0 */
  101.     rst_boot, clr_config, con_config, recv_boot,
  102.     send_config, NULLFCN, unload_ok,
  103.     "MEMSIZ - ROSE Memory Utilization Display\r"
  104. };
  105.  
  106. extern unsigned int MEMSIZ, HEAPUSD;
  107. extern struct datastr *l2_user_info, l2_info;
  108.  
  109. struct datastr *mkpkt();
  110.  
  111. char cnf_busy;
  112. struct datastr *cnf_in;
  113.  
  114. putdec(bp, val, w)
  115. struct datastr *bp;
  116. unsigned int val;
  117. int w;
  118. {
  119.     static char z[10];
  120.     static unsigned int v, u10;
  121.     static int i;
  122.  
  123.     u10 = 10;
  124.     for (i=0;i<10;i++) z[i]=' ';
  125.     z[9]=0;
  126.     v=val;
  127.     for (i=8;i>=0, v!=0;i--) /* Stuff one digit at a time */ {
  128.         z[i] = '0' + (v - (v/u10)*u10);
  129.         v = v / 10;
  130.     }
  131.     bappstr(bp, &z[9-w]);
  132. }
  133.  
  134. int
  135. con_config(vc)
  136. register struct VCS *vc;
  137. {
  138.     static int (*fn)();
  139.     extern struct datastr *frag_pkt();
  140.  
  141.     vc=vc->peer;
  142.     if (!vc) return;
  143.     fn=vc->SEND;
  144.     puthex2("con",vc,"at",fn);
  145.     (*fn)(vc,info_pkt());
  146.     if (cnf_busy) {
  147.         (*fn)(vc,mkpkt("Busy\r"));
  148.         set_p(vc,P6,Number_Busy);
  149.     }
  150.     else {
  151.         cnf_busy=TRUE;
  152.     }
  153. }
  154.  
  155. int
  156. clr_config(vc,c)
  157. struct VCS *vc;
  158. int c;
  159. {
  160.     cnf_busy=FALSE;
  161.     set_p(vc, P1, 0);
  162. }
  163.  
  164. int
  165. send_config(vc, pkt)
  166. register struct VCS *vc;
  167. struct datastr *pkt;
  168. {
  169.     static int i, ch;
  170.  
  171.     puthex2("send fig",vc,"",pkt);
  172.     vc_queue_data(vc,pkt);
  173.     while ((cnf_in = vc->tx_queue)) /* There is stuff waiting */ {
  174.         vc->tx_queue = cnf_in->next;
  175.         free_buffer(cnf_in);
  176.         cnf_in=mkpkt("\rMemory Size is: ");
  177.         putdec(cnf_in, MEMSIZ, 7);
  178.         bappstr(cnf_in," Bytes\rMemory Used is: ");
  179.         putdec(cnf_in, HEAPUSD, 7);
  180.         bappstr(cnf_in, " Bytes\r");
  181.         (*vc->peer->SEND)(vc->peer, cnf_in);
  182.     }
  183.     return 256;    /* We are never busy! */
  184. }
  185.  
  186.